unix-ffi: Fixing behavior to avoid zombie threads.#1046
Open
klukonin wants to merge 1 commit intomicropython:masterfrom
Open
unix-ffi: Fixing behavior to avoid zombie threads.#1046klukonin wants to merge 1 commit intomicropython:masterfrom
klukonin wants to merge 1 commit intomicropython:masterfrom
Conversation
This commit is fixing this issue: micropython#780 Now the pid of child thread will be stored and closed properly. Even with context manager. Signed-off-by: Kirill Lukonin (Evil Wireless Man) <klukonin@gmail.com>
|
bump up |
Contributor
|
It would be good to add a test for this functionality, Other tests for the ffi module live in the micropython repo under tests/ports/unix you could take one of the other ffi_ tests as the base, and add example code to it. |
dpgeorge
reviewed
Dec 2, 2025
|
|
||
| class _PopenStream: | ||
| def __init__(self, fd, pid, mode): | ||
| self._fd = open(f"/dev/fd/{fd}", mode) |
Member
There was a problem hiding this comment.
This needs to use builtins.open so that the returned object is a stream.
| pid, status = waitpid(self._pid, 0) | ||
| self._exitcode = status | ||
| self._closed = True | ||
| return self._exitcode |
Member
There was a problem hiding this comment.
This _PopenStream object will need to implement read/write/etc operations, so that you can communicate with the process.
Eg prior to this patch it's possible to do:
import os
ls = os.popen("/bin/ls")
print(ls.read())
ls.close()and that still needs to work.
Author
|
I'll update the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit is fixing this issue:
#780
As discussed here https://github.com/orgs/micropython/discussions/13239
Now the pid of child thread will be stored and closed properly. Even with context manager.